package com.jztd.servone.invoice.service.impl;

import cn.xbatis.core.sql.executor.chain.QueryChain;
import cn.xbatis.datasource.routing.DS;
import com.jztd.servone.invoice.mapper.BusinessConfigMapper;
import com.jztd.servone.invoice.po.BusinessConfig;
import com.jztd.servone.invoice.service.BusinessConfigService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@DS("invoice")
@Slf4j
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class BusinessConfigServiceImpl implements BusinessConfigService {
    private final BusinessConfigMapper businessConfigMapper;
    @Override
    public BusinessConfig getBusinessConfig(String clientType,String clientCode) {
        BusinessConfig businessConfig = QueryChain.of(businessConfigMapper)
                .eq(BusinessConfig::getType, clientType)
                .eq(BusinessConfig::getCode, clientCode)
                .get();
        return businessConfig;
    }

    @Override
    public BusinessConfig getBusinessConfig(String clientCode) {
        BusinessConfig businessConfig = QueryChain.of(businessConfigMapper)
                .eq(BusinessConfig::getCode, clientCode)
                .get();
        return businessConfig;
    }
}
